home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Source.bin / TabPanelBeanInfo.java < prev    next >
Text File  |  1998-10-03  |  6KB  |  173 lines

  1. package symantec.itools.awt;
  2.  
  3. import java.beans.*;
  4. import symantec.itools.beans.*;
  5. import java.util.ResourceBundle;
  6.  
  7. //  08/19/98    LAB    Moved to GroupAWTAdditions folder.
  8.  
  9. /**
  10.  * BeanInfo for TabPanel.
  11.  *
  12.  */
  13.  
  14. public class TabPanelBeanInfo extends SimpleBeanInfo {
  15.  
  16.     /**
  17.      * Constructs a TabPanelBeanInfo object.
  18.      */
  19.     public TabPanelBeanInfo() {
  20.     }
  21.  
  22.     /**
  23.      * Gets a BeanInfo for the superclass of this bean.
  24.      * @return BeanInfo[] containing this bean's superclass BeanInfo
  25.      */
  26.     public BeanInfo[] getAdditionalBeanInfo() {
  27.         try {
  28.             BeanInfo[] bi = new BeanInfo[1];
  29.             bi[0] = Introspector.getBeanInfo(beanClass.getSuperclass());
  30.             return bi;
  31.         }
  32.         catch (IntrospectionException e) { throw new Error(e.toString());}
  33.     }
  34.  
  35.     /**
  36.      * Gets the SymantecBeanDescriptor for this bean.
  37.      * @return an object of type SymantecBeanDescriptor
  38.      * @see symantec.itools.beans.SymantecBeanDescriptor
  39.      */
  40.     public BeanDescriptor getBeanDescriptor() {
  41.         ResourceBundle group = ResourceBundle.getBundle("symantec.itools.resources.GroupBundle");
  42.         String s=group.getString("GroupAWTAdditions"); 
  43.  
  44.         SymantecBeanDescriptor bd = new SymantecBeanDescriptor(beanClass);
  45.         bd.setFolder(s);
  46.         bd.setWinHelp("0x123B2");
  47.  
  48.         bd.addAdditionalConnections(getAdditionalBeanInfo());
  49.  
  50.         return (BeanDescriptor) bd;
  51.     }
  52.  
  53.     /**
  54.      * Gets an image that may be used to visually represent this bean
  55.      * (in the toolbar, on a form, etc).
  56.      * @param iconKind the type of icon desired, one of: BeanInfo.ICON_MONO_16x16,
  57.      * BeanInfo.ICON_COLOR_16x16, BeanInfo.ICON_MONO_32x32, or BeanInfo.ICON_COLOR_32x32.
  58.      * @return an image for this bean, always color even if requested monochrome
  59.      * @see BeanInfo#ICON_MONO_16x16
  60.      * @see BeanInfo#ICON_COLOR_16x16
  61.      * @see BeanInfo#ICON_MONO_32x32
  62.      * @see BeanInfo#ICON_COLOR_32x32
  63.      */
  64.     public java.awt.Image getIcon(int iconKind) {
  65.         if (iconKind == BeanInfo.ICON_MONO_16x16 ||
  66.             iconKind == BeanInfo.ICON_COLOR_16x16) {
  67.             java.awt.Image img = loadImage("TabPanelC16.gif");
  68.             return img;
  69.         }
  70.  
  71.         if (iconKind == BeanInfo.ICON_MONO_32x32 ||
  72.             iconKind == BeanInfo.ICON_COLOR_32x32) {
  73.             java.awt.Image img = loadImage("TabPanelC32.gif");
  74.             return img;
  75.         }
  76.  
  77.         return null;
  78.     }
  79.  
  80.     /**
  81.      * Gets an array of descriptions of the methods used for "connections" by
  82.      * Visual CafΘ's Interaction Wizard.
  83.      * Included in each method description is a CONNECTIONS ConnectionDescriptor.
  84.      * @return method descriptions for this bean
  85.      * @see symantec.itools.beans.ConnectionDescriptor#CONNECTIONS
  86.      */
  87.     public MethodDescriptor[] getMethodDescriptors() {
  88.         Class[] args;
  89.         ConnectionDescriptor connection;
  90.         java.util.Vector connections;
  91.         java.util.Vector md = new java.util.Vector();
  92.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
  93.  
  94.         try{
  95.             args = new Class[1];
  96.             args[0] = java.lang.Integer.TYPE ;
  97.             MethodDescriptor setCurrentPanelNdx = new MethodDescriptor(beanClass.getMethod("setCurrentPanelNdx", args));
  98.  
  99.             connections = new java.util.Vector();
  100.             connection = new ConnectionDescriptor("input", "int", "",
  101.                                     "%name%.setCurrentPanelNdx(%arg%);",
  102.                                     conn.getString("setCurrentPanelNdx"));
  103.             connections.addElement(connection);
  104.  
  105.             setCurrentPanelNdx.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  106.             md.addElement(setCurrentPanelNdx);
  107.         } catch (Exception e) { throw new Error("setCurrentPanelNdx:: " + e.toString()); }
  108.  
  109.         try{
  110.             args = null;
  111.             MethodDescriptor getCurrentPanelNdx = new MethodDescriptor(beanClass.getMethod("getCurrentPanelNdx", args));
  112.  
  113.             connections = new java.util.Vector();
  114.             connection = new ConnectionDescriptor("output", "int", "",
  115.                                     "%name%.getCurrentPanelNdx()",
  116.                                     conn.getString("getCurrentPanelNdx"));
  117.             connections.addElement(connection);
  118.  
  119.             getCurrentPanelNdx.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  120.             md.addElement(getCurrentPanelNdx);
  121.         } catch (Exception e) { throw new Error("getCurrentPanelNdx:: " + e.toString()); }
  122.  
  123.         MethodDescriptor[] rv = new MethodDescriptor[md.size()];
  124.         md.copyInto(rv);
  125.  
  126.         return rv;
  127.     }
  128.  
  129.     /**
  130.      * Returns descriptions of this bean's properties.
  131.      */
  132.     public PropertyDescriptor[] getPropertyDescriptors() {
  133.         ResourceBundle prop = ResourceBundle.getBundle("symantec.itools.resources.PropBundle");
  134.  
  135.         try{
  136.         PropertyDescriptor defProperty = new PropertyDescriptor("currentPanelNdx", beanClass);
  137.         defProperty.setBound(true);
  138.         defProperty.setConstrained(true);
  139.         defProperty.setDisplayName(prop.getString("currentPanelNdx"));
  140.         defProperty.setValue("codeGenAfterEmbedded",Boolean.TRUE);
  141.         
  142.         PropertyDescriptor panelLabels = new PropertyDescriptor("panelLabels", beanClass);
  143.         panelLabels.setBound(true);
  144.         panelLabels.setConstrained(true);
  145.         panelLabels.setDisplayName(prop.getString("panelLabels"));
  146.  
  147.         PropertyDescriptor tabsOnBottom = new PropertyDescriptor("tabsOnBottom", beanClass);
  148.         tabsOnBottom.setBound(true);
  149.         tabsOnBottom.setConstrained(true);
  150.         tabsOnBottom.setDisplayName(prop.getString("tabsOnBottom"));
  151.  
  152.         PropertyDescriptor layout = new PropertyDescriptor("layout", beanClass);
  153.         layout.setHidden(true);
  154.  
  155.         PropertyDescriptor[] rv = {
  156.             defProperty,
  157.             panelLabels,
  158.             tabsOnBottom,
  159.             layout};
  160.         return rv;
  161.         } catch (IntrospectionException e) { throw new Error(e.toString()); }
  162.     }
  163.  
  164.     /**
  165.      * Returns the index of the property expected to be changed most often by the designer.
  166.      */
  167.     public int getDefaultPropertyIndex() {
  168.         return 0;    //  the index for our default property is always 0
  169.     }
  170.  
  171.     private final static Class beanClass = TabPanel.class;
  172.  
  173.     }    //  end of class TabPanelBeanInfo